package com.douqu.game.core.entity.db;

import com.bean.core.buffer.ByteBuffer;
import com.douqu.game.core.config.LotteryConfig;

/**
 * @author: Gavin.
 * Description:
 * Date: 2018/2/11 0011 上午 10:09
 * Huan Yu Copyright (c) 2017 All Rights Reserved.
 */
public class LotteryDB extends DB {


    /**当前抽奖次数*/
    public int currentNum;

    public int max;


    public LotteryDB(int dataKey) {
        super(dataKey);

        max = Integer.MAX_VALUE / 10 * 10;
    }

    public LotteryDB(int dataKey,int id) {
        super(dataKey,id);

        max = Integer.MAX_VALUE / 10 * 10;
    }

    @Override
    public void loadFrom(ByteBuffer buffer)
    {
        super.loadFrom(buffer);
        currentNum = buffer.readInt();

    }

    @Override
    public void writeTo(ByteBuffer buffer)
    {
        super.writeTo(buffer);
        buffer.writeInt(currentNum);
    }


    public int init(){
        return 0;
    }

    @Override
    public void reset() {

    }

    public void checkReset(){

    }

    public void clear(){

    }

    public boolean isTodayByOffset()
    {
        return true;
    }

    public boolean checkCDTime(){
        return true;
    }

    public boolean checkFreeCount(){
        return false;
    }


    public void addCurrentCount(){
        currentNum++;
        currentNum = currentNum > max ? 0 : currentNum;
    }

    public void setCdTime(){

    }
    public int getFreeCount()
    {
        return 0;
    }

    public int getCDTime()
    {
        return 0;
    }

    public long getLastUpdateTime()
    {
        return 0;
    }

    @Override
    public LotteryConfig getConfig() {
        return (LotteryConfig) super.getConfig();
    }
}
